/*
 * Copyright 2011-2012 INSA Rennes
 *
 * This file is part of EIImage.
 *
 * EIImage is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * EIImage is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with EIImage.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <QDialog>
#include <QFormLayout>
#include <QComboBox>
#include <QSpinBox>
#include <QDialogButtonBox>
#include <GrayscaleImage.h>
#include <QGroupBox>
#include <QRadioButton>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QFileDialog>
#include <QApplication>
#include "ZoomDialog.h"

using namespace imagein;

ZoomDialog::ZoomDialog(QWidget *parent) : QDialog(parent) {

    this->setWindowTitle(QString(qApp->translate("Operations in window", "Zoom")));
    this->setMinimumWidth(180);
    QFormLayout* layout = new QFormLayout();
    this->setLayout(layout);

    _zoombox = new QLineEdit();
    _zoombox->setText(tr("200"));

    QComboBox* algoBox = new QComboBox();
    algoBox->addItem(qApp->translate("Zoom", ""));
    algoBox->addItem(qApp->translate("Zoom", "25"));
    algoBox->addItem(qApp->translate("Zoom", "50"));
    algoBox->addItem(qApp->translate("Zoom", "75"));
    algoBox->addItem(qApp->translate("Zoom", "200"));
    algoBox->addItem(qApp->translate("Zoom", "400"));
    algoBox->addItem(qApp->translate("Zoom", "800"));

    layout->insertRow(0, qApp->translate("Zoom", "value of the zoom(%) : "), _zoombox);
    layout->insertRow(1, qApp->translate("Zoom", "value of the zoom(%) : "), algoBox);

    QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel, Qt::Horizontal, this);
    layout->insertRow(2, buttonBox);
    QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    QObject::connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
    QObject::connect(algoBox, SIGNAL(currentIndexChanged(const QString &)), _zoombox, SLOT(setText(const QString &)));

}//end Constructor

int ZoomDialog::getzoomvalue(){
    QString * value = new QString(_zoombox->text() );
    int zoomscale;
    bool ok = true;
    zoomscale = value->toInt(&ok);
    return zoomscale;
}






